package com.glodon.zhuanli.config;

import com.glodon.framework.web.config.WebConfigForJSP;
import com.glodon.framework.web.filter.RequestEscapeFilter;
import com.glodon.framework.web.filter.RequestRefererFilter;
import com.glodon.framework.web.init.WebXMLInitializer;
import com.glodon.infrastructure.config.local.SessionLocalConfig;

public class ZhuanliWebXMLInitializer extends WebXMLInitializer {

	/**
	 * 配置spring加载需要的类
	 */
	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class[]{
				ZhuanliConfig.class ,
				SessionLocalConfig.class ,
				ZhuanliSecurityConfig.class
		} ;
	}
	/**
	 * 配置springmvc配置需要的类
	 */
	@Override
	protected Class<?>[] getServletConfigClasses() {
		return new Class[]{WebConfigForJSP.class};
	}

	@Override
	protected void configRequestRefererFilter(RequestRefererFilter requestRefererFilter){
		//对所有的url请求都不进行校验
		requestRefererFilter.addExcludeURLPattern("/**");
	}
	
	@Override
	protected String[] getServletMappings() {
		return new String[]{"/"};
	}
	
	/**
	 * 注册自定义的Filter，父方法中已经添加了shiro、encoder过滤器。重载添加自定义的过滤器
	 */
	@Override
	protected void registerCustomFilters(){
		super.registerCustomFilters() ;
	}

	@Override
	protected void addExcludeRequestEscapeURL(RequestEscapeFilter requestEscapeFilter){
		requestEscapeFilter.addExcludeURLPattern("/**") ;
	}

}
